CREATE TABLE [dbo].[tb_EstadosConcursos]
(
[idEstadoConcurso] [int] NOT NULL IDENTITY(1, 1),
[Descripcion] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[updatetb_EstadosConcursos] ON [dbo].[tb_EstadosConcursos]
 FOR UPDATE AS 
SET NOCOUNT ON
 IF (update(idEstadoConcurso)) begin 
	 SELECT * FROM inserted 
	 IF @@ROWCOUNT = 1 begin 
		 UPDATE tb_Concursos
		 SET Estado = (SELECT idEstadoConcurso FROM inserted)
		 WHERE tb_Concursos.Estado = (SELECT idEstadoConcurso FROM deleted)
	end  ELSE begin 
		 ROLLBACK TRANSACTION 
 end 
 end

GO
ALTER TABLE [dbo].[tb_EstadosConcursos] ADD CONSTRAINT [PK_tb_EstadosConcursos] PRIMARY KEY NONCLUSTERED  ([idEstadoConcurso]) ON [PRIMARY]
GO
